



int index = 0;
int i =0;
int j= 0;

float sum = pK->close;

for(i=1;i<AvrSize;i++)
{
    index = pK->index - i;
    
    while(1)
    {
        if((index == (pK-i-j)->index) && ((pK-i-j)->weekFlag == 1))
        {
            sum += (pK-i-j)->close;
            j++;
            break;
        }
        j++;
    }
}
